<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.fick.hibernate.model.*"%>
<%@ page import="com.fick.hibernate.dao.*"%>
<%@ page import="com.fick.util.Pager" %>
<%@page import="java.text.SimpleDateFormat"%>
<%@ include file="../tld/tlds.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>通讯录管理</title>
<link href="images/jiahao.css" rel="stylesheet" type="text/css">

		<link href="css/css.css" rel="stylesheet" type="text/css" />
		<script language="JavaScript" src="js/meihuaxue.js"></script>
		<script language="javaScript" src="js/prototype.js"></script>
		<script type="text/javascript" src="js/submit.js"></script>
		<script language="javascript" type="text/javascript" src="My97DatePicker/WdatePicker.js" defer="defer"></script>
</head>

<body>

<%
	Txlfick txl;
	List li2=(List)request.getAttribute("list");
	int totalCount=(Integer)request.getAttribute("totalCount");
	int currPage=(Integer)request.getAttribute("currPage");
	int totalPage=(Integer)request.getAttribute("totalPage");
	String QueryString="";
	if(request.getAttribute("queryString")!=null)
	{
		QueryString=QueryString+(String)request.getAttribute("queryString");
	}
	if(request.getAttribute("queryString2")!=null)
	{
		QueryString=QueryString+(String)request.getAttribute("queryString2");
	}
 %>

<table width="100%"  height="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="100%" align="center" valign="top" background="images/main_bj.gif" bgcolor="#FBFCFD">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="23" align="left" valign="middle" background="images/main_top.gif">
        <table border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="20" height="23">&nbsp;</td>
            <td width="400" height="23" align="left" valign="middle" class="ts_lmdh2">通讯录管理 </td>
          </tr>
        </table></td>
      </tr>
    </table>
      	<form name="queryform" action="/admin/txlAction.do?method=findTxl" method="post">
			<script>
	 				function checkform()
	 				{
	 					queryform.submit();
	 				}
	 		</script>
			 <table  border="0" align="center" cellpadding="0" cellspacing="1" width="98%">
			 <tr>
			 	<td>
			 			按条件查询：<select name="property">
			 				<option value="">请选择</option>
			 				<option value="name">姓名</option>
			 				<option value="tel">内线</option>
			 				<option value="phone">手机</option>
			 				</select>
			 	</td>
			 	<td><input type="text" name="propertyValue"/></td>
			 	<td align="right">生日&nbsp;&nbsp;<input name="birthday" id="birthday" class="Wdate"
				type="text" size="22" readonly onclick="WdatePicker({skin:'default',dateFmt:'MM-dd'})" /></td>
			 	<td>
			 	<%Admin admin=(Admin)request.getSession().getAttribute("admin");    
				 if(admin!=null && (admin.getRole().getId() == 3 || admin.getRole().getId() == 5 ) )   //当超管时可以按所属单位查询
				 {
				  %>
			 	<td height="5" align="center">
			 	<%
			 		TxlDAO dao=new TxlDAO();
			 		List<String> unitList=dao.findBySql("SELECT distinct unit FROM admin where unit is not null"); 
			 	%>
			 		所属单位：<select name="unit">
			 				<option value="">请选择</option>
			 				<%
			 					for(int i = 0 ; i < unitList.size() ; i ++ ) {
			 					String unit = (String)unitList.get(i);
			 				%>
			 				<option value="<%=unit %>"><%=unit %></option>
			 				<%}%>
			 		</select>
			 	</td>
			 	<%}%>
			 	<td>
			 	<select name="searchtype" >
			 	<option value="0">精确查询</option>
			 	<option value="1">模糊查询</option>
			 	</select>
			 	</td>
			 	<td><input type="button" value="查询" onclick="checkform()"></td>
			 	<td height="20" align="right">&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="添加通讯录" onclick="window.location.href='addTxl.jsp'"></td>
			 </tr>
			 </table>
      <table width="98%" border="0" cellpadding="0" cellspacing="1" bgcolor="#D7DFE1">
        <tr>
		 <td width="6%" height="25" align="center" valign="middle" background="images/main_t_bj.gif" bgcolor="#FFFFFF" class="ts_lmdh">选择</td>
          <td width="15%" height="25" align="center" valign="middle" background="images/main_t_bj.gif" bgcolor="#FFFFFF" class="ts_lmdh">姓名</td>
          <td width="10%" height="25" align="center" valign="middle" background="images/main_t_bj.gif" bgcolor="#FFFFFF" class="ts_lmdh">生日</td>
          <td width="15%" height="25" align="center" valign="middle" background="images/main_t_bj.gif" bgcolor="#FFFFFF" class="ts_lmdh">内线</td>
          <td width="15%" height="25" align="center" valign="middle" background="images/main_t_bj.gif" bgcolor="#FFFFFF" class="ts_lmdh">手机</td>
          <td width="15%" height="25" align="center" valign="middle" background="images/main_t_bj.gif" bgcolor="#FFFFFF" class="ts_lmdh">所属单位</td>
          <td width="15%" height="25" align="center" valign="middle" background="images/main_t_bj.gif" bgcolor="#FFFFFF" class="ts_lmdh">备注</td>
          <td width="20%" height="25" align="center" valign="middle" background="images/main_t_bj.gif" bgcolor="#FFFFFF" class="ts_lmdh">操作</td>
        </tr>
       
	   <%
	   if(li2!=null)
	   {
		for(int i = 0 ; i < li2.size(); i++){
			txl = (Txlfick)li2.get(i);
										      
	 %>
	    <tr>
		<td width="6%" height="25" align="center" valign="middle" bgcolor="#FFFFFF">
		<input type="checkbox" name="MyCheckBox" id="MyCheckBox"
													value="<%=txl.getTxlId() %>" />
		</td>
          <td width="15%" height="25" align="center" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px">
		  <%=txl.getName()%>
		  </td>
		   <td width="10%" height="25" align="center" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px">
		  <%=txl.getAddTime()==null?"":new SimpleDateFormat("yyyy-MM-dd").format(txl.getAddTime())%>
		  </td>
		  <td width="15%" height="25" align="center" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px">
		  <%=txl.getTel()%>
		  </td>
		  <td width="15%" height="25" align="center" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px">
		  <%=txl.getPhone()%>
		  </td>
		  <td width="15%" height="25" align="center" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px">
			<%=txl.getUnit() %>
		  </td>
		  <td width="15%" height="25" align="center" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px">
		  <%=txl.getBz()%>
		  </td>
  			<td width="20%" height="25" align="center" valign="middle" bgcolor="#FFFFFF">
			<a href="addTxl.jsp?id=<%=txl.getTxlId()%>">修改</a>&nbsp;
			<a href="<%=request.getContextPath()%>/admin/txlAction.do?method=delByid&id=<%=txl.getTxlId()%>" onclick="javascript:return confirm('确定要删除吗删后将不可恢复')">删除</a>
			</td>
        </tr>
      <%
	  }
	  }
	  %>
	  
	  <tr>
		<td colspan="6" align="left">
		<input type="button" name="selectAlls" id="selectAlls" value="全选" onclick="return selectAll()" />
		<input type="button" name="noSelectAll" id="noSelectAll" value="反选" onclick="return selectOthers();" />
		<input type="button" name="cancelSelects" id="cancelSelects" value="取消选择" onclick="return cancelSelect();" />
		<input type="button" name="delAlls" id="delAlls" value="删除所选" onclick="return delAllTxl()"/>
		</td>
		<!-- 
		<%
		if(admin!=null && (admin.getRole().getId() == 3 || admin.getRole().getId() == 5 ) )   //当超管时可以按所属单位查询
		 {
		 %>
		<td colspan="2" align="right">
		<%
		IpAllowedStateDAO ipSDao = new IpAllowedStateDAO();
		List list = ipSDao.findAll();
		if(list!= null && list.size()!=0){
		IpAllowedState ipState = (IpAllowedState)list.get(0);
		if(ipState.getState().trim().equals("0")){
		 %>
			<input type="button" name="ipStateBtn" id="ipStateBtn" value="限制县外IP查询" onclick="lock()" />
		 <%
		 }else{
		  %>
			<input type="button" name="ipStateBtn" id="ipStateBtn" value="解除限制县外IP查询" onclick="unlock()" />
		  <%
		  }}
		   %>
		</td>
		<%} %>
		 -->
	</tr>
	  </table>
	  </form>
	  
	  <table width="98%" align="center" border="0" cellspacing="0" cellpadding="0">
		  	<tr><td align="center"><%=new Pager().nprintTable("/admin/txlAction.do?method=findTxl&",currPage,totalPage,totalCount,QueryString,QueryString)%></td></tr>
	  </table>
      </td>
  </tr>
</table>
<script type="text/javascript">
function unlock(){
	if(confirm('确定要解除限制县外IP吗？'))
		location.href="unlockIp.jsp";
}
function lock(){
	if(confirm('确定要限制县外IP吗？'))
		location.href="lockIp.jsp";
}
</script>
</body>
</html>
<script type="text/javascript">
<!--
var message = "<%=request.getAttribute("message")%>";
if(message!=null && message!="null" && message !=""){
   alert(message);
  }
  
 function gopage(selected)
 {
 	window.open(selected.value,"_self");
 }
//-->
</script>
